package com.taptech.doufu.ui.view;

import android.app.Activity;
import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.ColorDrawable;
import android.net.Uri;
import android.os.Bundle;
import android.text.Html;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.GridView;
import android.widget.PopupWindow;
import android.widget.TextView;
import android.widget.Toast;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.transition.Transition;
import com.douhuayuedu.douhua.wxapi.WXUtil;
import com.taptech.doufu.util.FetchResourceUtil;
import com.taptech.doufu.util.TTLog;
import com.taptech.doufu.util.TextUtil;
import com.taptech.doufu.R;
import com.taptech.doufu.ui.activity.NovelSectionDetailsActivity;
import com.taptech.doufu.ui.activity.SinaWeiboActivity;
import com.taptech.doufu.ui.adapter.TTShareAdapter;
import com.taptech.doufu.app.WeMediaApplication;
import com.taptech.doufu.bean.HomeTopBean;
import com.taptech.doufu.bean.NovelBean;
import com.taptech.doufu.bean.SweepBean;
import com.taptech.doufu.constant.GlobalConfig;
import com.taptech.doufu.constant.Constant;
import com.taptech.doufu.constant.Constant.WXData;
import com.taptech.doufu.bean.ShareBeansInfo;
import com.taptech.doufu.services.personalcenter.QQService;
import com.taptech.doufu.services.HomeMainServices;
import com.taptech.doufu.util.ImageManager;
import com.taptech.doufu.util.UIUtil;
import com.taptech.doufu.ui.view.colorful.Colorful;
import com.douhuayuedu.douhua.wxapi.WXEntryActivity;
import com.tencent.connect.share.QQShare;
import com.tencent.connect.share.QzoneShare;
import com.tencent.mm.opensdk.modelmsg.SendMessageToWX;
import com.tencent.mm.opensdk.modelmsg.WXMediaMessage;
import com.tencent.mm.opensdk.modelmsg.WXTextObject;
import com.tencent.mm.opensdk.modelmsg.WXVideoObject;
import com.tencent.mm.opensdk.modelmsg.WXWebpageObject;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;
import com.tencent.tauth.IUiListener;
import com.tencent.tauth.UiError;

import java.util.ArrayList;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

public class ShareTopPopupWindow extends PopupWindow {


    /**
     * 分享类型
     */
    private View mMenuView;
    private GridView mShareGridView;
    private Activity mContext;
    private ShareBeansInfo shareInfo;
    private Colorful colorful;
    // wx
    private IWXAPI wxAPI;

    public ShareTopPopupWindow(Activity context, int shrareType,boolean isNight) {
        super(context);
        colorful = new Colorful.Builder(context).create();
        if(context instanceof NovelSectionDetailsActivity){
            if (isNight) {
                colorful.setTheme(R.style.theme_dark);
            }else{
                colorful.setTheme(R.style.theme_day);
            }
        }else{
            if (WeMediaApplication.getInstance().isDayNightMode_Night) {
                colorful.setTheme(R.style.theme_dark);
            }else{
                colorful.setTheme(R.style.theme_day);
            }
        }

        this.mContext = context;
        registerShareServices();
        LayoutInflater inflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        mMenuView = inflater.inflate(R.layout.popup_share_panel, null);
        TextView tvTip = (TextView) mMenuView.findViewById(R.id.tvTip);
        if (!TextUtils.isEmpty(GlobalConfig.shareTip)) {
            tvTip.setText(Html.fromHtml(GlobalConfig.shareTip));
            tvTip.setVisibility(View.VISIBLE);
        }else{
            tvTip.setVisibility(View.GONE);
        }
        mShareGridView = (GridView) mMenuView
                .findViewById(R.id.gv_popup_share_content);
        TTShareAdapter adapter;
        if (shrareType == 1) {
            adapter = new TTShareAdapter(context, 1);
        } else
            adapter = new TTShareAdapter(context);
        adapter.setShartTopFlag(true);
        mShareGridView.setAdapter(adapter);
        // 设置SelectPicPopupWindow的View
        this.setContentView(mMenuView);
        // 设置SelectPicPopupWindow弹出窗体的宽
        this.setWidth(LayoutParams.MATCH_PARENT);
        // 设置SelectPicPopupWindow弹出窗体的高
        this.setHeight(LayoutParams.WRAP_CONTENT);
        // 设置SelectPicPopupWindow弹出窗体可点击
        this.setFocusable(true);
        // 设置SelectPicPopupWindow弹出窗体动画效果
        this.setAnimationStyle(R.style.Animation_Right_Left);
        ColorDrawable dw = new ColorDrawable(0x00000000);
        this.setBackgroundDrawable(dw);

        mShareGridView.setOnItemClickListener(new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view,
                                    final int position, long id) {
                dismiss();
//                HomeMainServices.getInstance().getShareUrlRequest(shareInfo.getId(),shareInfo.getObject_type(),null,shareInfo.shareUrl);
                int share_social_type = 100;
                switch (position) {
                    case TTShareAdapter.SHARE_TO_SINA_WEIBO:
                        share_social_type = 101;
                        shareInfo.setSocial_type(share_social_type);
                        shareToSinalWeibo(shareInfo);
                        break;

                    case TTShareAdapter.SHARE_TO_WEIXIN:
                        share_social_type = 102;
                        shareInfo.setSocial_type(share_social_type);
                        shareToWeixin(shareInfo);
                        break;

                    case TTShareAdapter.SHARE_TO_PENGYOUQUAN:
                        share_social_type = 103;
                        shareInfo.setSocial_type(share_social_type);
                        shareToPengyouquan();
                        break;
                    case TTShareAdapter.SHARE_TO_TECENT_QQ:
                        share_social_type = 104;
                        shareInfo.setSocial_type(share_social_type);
                        shareQQ(shareInfo);
                        break;
                    case TTShareAdapter.SHARE_TO_TECENT_SPACE:
                        share_social_type = 105;
                        shareInfo.setSocial_type(share_social_type);
                        shareQQSpace();
                        break;
                    case TTShareAdapter.SHARE_TO_MESSAGE:
                        share_social_type = 100;
                        shareInfo.setSocial_type(share_social_type);
                        shareToMessage();
                        break;

                    case TTShareAdapter.SHARE_TO_EMAIL:
                        share_social_type = 106;
                        shareInfo.setSocial_type(share_social_type);
                        shareToEmail();
                        break;
                    case TTShareAdapter.SHARE_TO_SYSTEM_MORE:
                        shareToSystemMore();
                        break;
                    case TTShareAdapter.COPY_THE_SHARE_LINK:
                        if (shareInfo != null && shareInfo.getShareUrl() != null) {
                            UIUtil.toastMessage(mContext, "复制链接成功");
                            TextUtil.copyString2Clipboard(mContext, shareInfo.getShareUrl());
                        }
                        break;
                    default:
                        break;
                }

            }
        });
    }

    public ShareTopPopupWindow(Activity context) {
        this(context, 0,false);
    }

    public ShareTopPopupWindow(Activity context,boolean isNight) {
        this(context, 0,isNight);
    }

    private void registerShareServices() {
        // wx
        wxAPI = WXAPIFactory.createWXAPI(mContext, Constant.WX_APP_ID, true);
        wxAPI.registerApp(Constant.WX_APP_ID);
    }

    public void setShareBeans(ShareBeansInfo shareInfo) {
        this.shareInfo = shareInfo;
    }

    @SuppressWarnings("null")
    public void shareToSinalWeibo(ShareBeansInfo shareInfo) {
        String shareURL = "";
        if (shareInfo.getShareData() != null) {
            shareURL = shareInfo.getShareData().getShareUrl();
        } else {
            shareURL = shareInfo.getShareUrl();
        }
        if (shareURL == null) {
            shareURL = Constant.DOWN_URL_WB;
        }
        String shareText = "";
        final String SINA_SHARE_FOOT = " 下载  @豆花  ：" + Constant.DOWN_URL_WB;
        switch (shareInfo.getFlag()) {
            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                shareText = "《" + shareInfo.getTitle() + "》" + shareURL
                        + "来自#豆花# @豆花客户端";
                break;
            case ShareBeansInfo.PHOTO_SHARE_FLAG:
                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_FLAG) {
                    shareText = "#豆花撸妹子#我觉得这个妹子不错，大家觉得这个妹子值多少分？分享自@豆花客户端 "
                            + shareURL;
                } else {
                    shareText = "我在#豆花#里面发现这张图屌炸天了！更多宅腐内容尽在豆花，你们也快来下载吧!" + Constant.DOWN_URL_WB;

                }
                break;
            case ShareBeansInfo.WOED_SHARE_FlAG:
                shareText = "(分享自@豆花客户端" + shareURL + ")" + " #豆花#"
                        + shareInfo.getImagUrl();
                break;
            // 分享 新浪 视频
            case ShareBeansInfo.VIDEO_SHARE_FLAG:

                shareText = "我在看到一个很棒的视频《" + shareInfo.getTitle() + "》" + "(查看详情：    " + shareURL + SINA_SHARE_FOOT + ")";
                break;
            case ShareBeansInfo.TOPIC_SHARE_FLAG:
                if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                    shareText = subString("《" + shareInfo.getTitle() + "》 " + shareInfo.getDescription(), 60) + "(查看详情： " + shareURL + SINA_SHARE_FOOT + ")";
                } else {
                    shareText = subString("《" + shareInfo.getTitle() + "》 ", 60) + "(查看详情： " + shareURL + SINA_SHARE_FOOT + ")";
                }

                break;
            // 分享 新浪 小说
            case ShareBeansInfo.NOVEL_SHARE_FLAG:

                String[] tagStrings = new String[3];
                String tagsString = "";
                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    tagsString += "#";
                    tagStrings = shareInfo.getTags();
                    for (int i = 0; i < ((tagStrings.length < 3) ? tagStrings.length : 3); i++) {
                        tagsString += (tagStrings[i] + "##");
                    }
                    if (tagsString != null && tagsString.length() > 0) {
                        tagsString = tagsString.substring(0, tagsString.length() - 1);
                    }
                }
                shareText = "我最近在#豆花#读《"+shareInfo.getTitle()+"》"+tagsString+"，觉得不错，介绍给你们@豆花阅读 试读："+shareURL;
                break;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:
//			shareText =shareInfo.getShartText()+shareInfo.shareUrl;
                shareText = shareInfo.getShartText() + shareChannel(shareInfo.shareUrl, Constant.ShareChannel.SinaWeibo);
                break;
            // 分享 新浪 文评
            case ShareBeansInfo.SWEEP_SHARE_FLAG:
                if (shareInfo.getShareData() != null && shareInfo.getShareData().getSweep() != null) {
                    SweepBean sweepBean = shareInfo.getShareData().getSweep();
                    String sweepTag = "";
                    String sweepLevel = "";
                    String sweepContent = "";

                    String[] tags = sweepBean.getTag_list().split("\\s+");
                    String sweepTagsString = "#";

                    for (int i = 0; i < ((tags.length < 3) ? tags.length : 3); i++) {
                        sweepTagsString += (tags[i] + "##");
                    }
                    if (sweepTagsString != null || sweepTagsString.length() > 0) {
                        sweepTagsString = sweepTagsString.substring(0, sweepTagsString.length() - 1);
                    }
                    sweepContent = sweepBean.getReview();
                    NovelBean novelBean = shareInfo.getNovelBean();
                    if (novelBean == null) {
                        return;
                    }
                    String showContent = "";
                    if (!TextUtils.isEmpty(sweepContent)){
                        if (sweepContent.length() > 60) {
                            showContent = subString(sweepContent, 60) + "...";
                        }else{
                            showContent = sweepContent;
                        }
                    }
                    shareText = "#豆花文评#"  + novelBean.getTitle() + "，"  + sweepTagsString + "，" + showContent
                            + " @豆花文评组 文评详情：" + shareURL;

                }
                break;
            // 分享 新浪 日常
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                String sinaTag = "";
                String noteTitle = "";
                String noteContent = "";
                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    sinaTag = "#" + shareInfo.getTags()[0] + "#";
                }
                if (shareInfo.getDescription() != null) {
                    if (shareInfo.getDescription().length()>60){
                        noteContent = subString(shareInfo.getDescription(), 60) + "...";
                    }else{
                        noteContent = shareInfo.getDescription() ;
                    }
                }
                if (shareInfo.getTitle() != null) {
                    noteTitle = shareInfo.getTitle();
                }
                if (shareInfo.getObject_type().equals("41")) {
                    if (!TextUtils.isEmpty(noteTitle)) { //有标题
                        if (!TextUtils.isEmpty(noteContent)) { //有正文
                            shareText = sinaTag+noteTitle+"："+noteContent+"(围观请戳："+shareInfo.getShareUrl() + SINA_SHARE_FOOT + ")";
                        }else{
                            shareText = sinaTag+noteTitle+"(围观请戳："+shareInfo.getShareUrl() + SINA_SHARE_FOOT + ")";
                        }
                    }else{
                        if (!TextUtils.isEmpty(noteContent)) { //有正文
                            shareText = "我参与了豆花的"+sinaTag+"话题："+noteContent+"(围观请戳："+shareInfo.getShareUrl()  + ")";
                        }else{
                            shareText = "我参与了豆花的"+sinaTag+"话题，围观请戳："+shareInfo.getShareUrl() ;
                        }
                    }
                } else if (shareInfo.getObject_type().equals("42")) {
                    shareText = "#就怕腐女会画画#" + "《" + noteTitle + "》" + noteContent + "(查看详情：" + shareInfo.getShareUrl() + SINA_SHARE_FOOT + ")";
                } else if (shareInfo.getObject_type().equals("43")) {
                    shareText = "#豆花Coser#" + "《" + noteTitle + "》" + noteContent + "(查看详情：" + shareInfo.getShareUrl() + SINA_SHARE_FOOT + ")";
                }
                break;
            // 分享 新浪 漫画
            case ShareBeansInfo.CARTOON_SHARE_FLAG:
                String cartoonTag = "";

                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    sinaTag = "【" + shareInfo.getTags()[0] + "】";
                }
                String cartoonDes = "";
                if (shareInfo.getDescription() != null) {

                    noteContent = cartoonTag + "《" + subString(shareInfo.getDescription(), 60) + "》";
                }
                String[] tStrings = new String[3];
                String tString = "#";
                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    tStrings = shareInfo.getTags();
                    for (int i = 0; i < ((tStrings.length < 3) ? tStrings.length : 3); i++) {
                        tString += (tStrings[i] + "##");
                    }
                    if (tString != null && tString.length() > 0) {
                        tString = tString.substring(0, tString.length() - 1);
                    }
                }
                String cartoonTitle = "";
                cartoonTitle = shareInfo.getTitle();
                StringBuilder contentSb = new StringBuilder();
                contentSb.append("我最近在#豆花#追《");
                contentSb.append(cartoonTitle);
                contentSb.append("》");
                contentSb.append(tString);
                contentSb.append("，超好看，介绍给你@豆花原创漫画 试看：");
                contentSb.append(shareInfo.getShareUrl());
                shareText = contentSb.toString();
                break;

            default:
                break;
        }
        shareInfo.setShartText(shareText);
        Intent intent = new Intent(mContext, SinaWeiboActivity.class);

        if (shareInfo.getShareData() != null && shareInfo.getShareData().getImages() != null && shareInfo.getShareData().getImages().length > 0 && shareInfo.getShareData().getImages()[0].getImgUrl() != null) {
            intent.putExtra("imgPath", shareInfo.getShareData().getImages()[0].getImgUrl());
        }
        intent.putExtra("flag", shareInfo.getFlag());
        intent.putExtra("shareInfo", shareInfo);
        mContext.startActivity(intent);

    }



    // 分享 微信
    public void shareToWeixin(final ShareBeansInfo shareInfo) {
        WXEntryActivity.Companion.setShareInfo(shareInfo);
        String shareURL;
        if (shareInfo.getShareData() != null) {
            shareURL = shareInfo.getShareData().getShareUrl();
        } else {
            shareURL = shareInfo.getShareUrl();
        }
        if (shareURL == null) {
            shareURL = Constant.DOWN_URL_WX;
        }
        WXMediaMessage msg = null;
        WXTextObject textObj = null;
        switch (shareInfo.getFlag()) {
            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                Bitmap bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());

                if (bmp == null) {
                    bmp = FetchResourceUtil.fetchBitmap(mContext.getResources(),
                            R.drawable.new_icon);
                }
                WXWebpageObject webpageObj = new WXWebpageObject();
                webpageObj.webpageUrl = shareURL;
                msg = new WXMediaMessage(webpageObj);
                msg.title = shareInfo.getTitle();
                msg.description = "内容太劲爆了..";
                if (bmp != null) {
                    Bitmap thumbBmp = Bitmap
                            .createScaledBitmap(bmp, WXData.THUMB_WIDTH_SIZE,
                                    WXData.THUMB_HEIGHT_SIZE, true);
                    msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                }
                break;

            case ShareBeansInfo.PHOTO_SHARE_FLAG:

                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_SHAKE) {
                    // 初始化一个WXTextObject对象
                    textObj = new WXTextObject();
                    if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_FLAG) {
                        textObj.text = "妹子求评分！" + shareInfo.getImagUrl();
                    } else {
                        textObj.text = shareInfo.getImagUrl();
                    }
                    // 用WXTextObject对象初始化一个WXMediaMessage对象
                    msg = new WXMediaMessage();
                    msg.mediaObject = textObj;
                    if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_FLAG) {
                        msg.description = "妹子求评分";
                    }
                } else {
                    bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());
                    if (bmp == null) {
                        bmp = FetchResourceUtil.fetchBitmap(
                                mContext.getResources(), R.drawable.new_icon);
                    }
                    webpageObj = new WXWebpageObject();
                    webpageObj.webpageUrl = shareURL;
                    msg = new WXMediaMessage(webpageObj);
                    msg.title = "小心亮瞎你的狗眼...";
                    msg.description = shareInfo.getTitle();
                    if (bmp != null) {
                        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,
                                WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE,
                                true);
                        msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                    }
                }
                break;
            case ShareBeansInfo.WOED_SHARE_FlAG:
                // 初始化一个WXTextObject对象
                textObj = new WXTextObject();
                // 用WXTextObject对象初始化一个WXMediaMessage对象
                textObj.text = " #豆花#" + shareInfo.getImagUrl() + "(分享自@豆花客户端"
                        + shareInfo.getShareUrl() + ")";
                msg = new WXMediaMessage();
                msg.mediaObject = textObj;
                msg.description = shareInfo.getTitle();
                break;
            // 分享 微信 视频
            case ShareBeansInfo.VIDEO_SHARE_FLAG:
                WXVideoObject video = new WXVideoObject();
                video.videoUrl = shareURL;
                msg = new WXMediaMessage(video);
                msg.title = shareInfo.getShareData().getTitle();
                msg.description = "来自豆花App，女性向创作社区";

                Bitmap thumb = BitmapFactory.decodeResource(
                        WeMediaApplication.applicationContext.getResources(),
                        R.drawable.new_icon);
                thumb = Bitmap.createScaledBitmap(thumb, WXData.THUMB_WIDTH_SIZE,
                        WXData.THUMB_HEIGHT_SIZE, true);
                msg.thumbData = WXUtil.bmpToByteArray(thumb, true);
                break;
            // 分享 微信 话题
            case ShareBeansInfo.TOPIC_SHARE_FLAG:
                webpageObj = new WXWebpageObject();
                webpageObj.webpageUrl = shareURL;
                msg = new WXMediaMessage(webpageObj);

                msg.title = subString(shareInfo.getTitle(), 25);
                if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                    msg.description = subString(shareInfo.getDescription(), 35);
                } else {
                    msg.description = "来自豆花App，女性向创作社区";
                }
                if (shareInfo.getImagUrl() != null) {
                    bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());

                    if (bmp == null) {
                        bmp = FetchResourceUtil.fetchBitmap(
                                mContext.getResources(), R.drawable.new_icon);
                    }
                    if (bmp != null) {
                        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,
                                WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE,
                                true);
                        msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                    }
                }
                break;
            // 分享 微信 小说
            case ShareBeansInfo.NOVEL_SHARE_FLAG:
                String url = Constant.LOGO_URL;
                if (!TextUtils.isEmpty(shareInfo.getImagUrl())) {
                    url = shareInfo.getImagUrl();
                }
                url = Constant.changeUrlHost(url);
                Glide.with(WeMediaApplication.applicationContext).asBitmap().load(url).into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(@NonNull Bitmap logoBitmap, @Nullable Transition<? super Bitmap> transition) {
                        WXWebpageObject novelpageObj = new WXWebpageObject();
                        WXMediaMessage msg = new WXMediaMessage(novelpageObj);
                        novelpageObj.webpageUrl = shareInfo.getShareData().getShareUrl();
                        if (!TextUtils.isEmpty(shareInfo.getTitle())){
                            if (shareInfo.getTitle().length() > 25) {
                                msg.title = subString(shareInfo.getTitle(), 25)+"...";
                            }else{
                                msg.title = shareInfo.getTitle();
                            }
                        }
                        if (!TextUtils.isEmpty(shareInfo.getShartText())) {
                            if (shareInfo.getShartText().length() > 35) {
                                msg.description = subString(shareInfo.getShartText(), 35)+"...";
                            }else{
                                msg.description = shareInfo.getShartText();
                            }
                        }else{
                            msg.description = "我最近在读的小说，介绍给你";
                        }
                        if (logoBitmap == null) {
                            logoBitmap = FetchResourceUtil.fetchBitmap(mContext.getResources(),
                                    R.drawable.new_icon);
                        }
                        if (logoBitmap != null) {
                            Bitmap thumbBmp = ImageUtil.centerSquareScaleBitmap(logoBitmap, WXData.THUMB_WIDTH_SIZE);
                            msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                        }
                        SendMessageToWX.Req req = new SendMessageToWX.Req();
                        req.scene = SendMessageToWX.Req.WXSceneSession; // for wechat friends
                        req.transaction = String.valueOf(System.currentTimeMillis());
                        req.message = msg;
                        boolean flag = wxAPI.sendReq(req);
                    }

                });

                return;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:
                Bitmap rankBitmap = FetchResourceUtil.fetchBitmap(mContext.getResources(), R.drawable.new_icon);

                WXWebpageObject rankpageObj = new WXWebpageObject();
                rankpageObj.webpageUrl = shareChannel(shareInfo.getShareUrl(), Constant.ShareChannel.Weixin);
                msg = new WXMediaMessage(rankpageObj);
                msg.title = "腐化度测试";
//			msg.description =shareInfo.getShartText() ;
                msg.description = shareChannel(shareInfo.getShartText(), Constant.ShareChannel.Weixin);
                if (rankBitmap != null) {
                    Bitmap thumbBmp = Bitmap.createScaledBitmap(rankBitmap, WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE, true);
                    msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                }
                break;
            //分享 微信 文评
            case ShareBeansInfo.SWEEP_SHARE_FLAG:
                WXWebpageObject sweeppageObj = new WXWebpageObject();
                sweeppageObj.webpageUrl = shareInfo.getShareUrl();

                SweepBean sweepBean = shareInfo.getShareData().getSweep();
                String sweepTitle = "";
                String sweepTag = "";
                String sweepLevel = "";
                String sweepContent = "";
                String[] tags = sweepBean.getTag_list().split("\\s+");
                NovelBean novelBean = shareInfo.getNovelBean();
                if (tags != null && tags.length > 0) {

                    sweepTag = tags[0];
                } else sweepTag = "";
                sweepLevel = UIUtil.showStarLevel(Integer.valueOf(sweepBean.getStar()));
                if (sweepBean.getReview() != null) {
                    sweepContent = sweepBean.getReview();
                }
                msg = new WXMediaMessage(sweeppageObj);
                String showTitle ;
                if (!TextUtils.isEmpty(novelBean.getTitle())) {
                    showTitle = "【豆花文评】"+novelBean.getTitle();
                }else{
                    showTitle = "【豆花文评】";
                }
                if (showTitle.length() > 25) {
                    msg.title = subString(showTitle, 25);
                }else{
                    msg.title = showTitle;
                }
                if (!TextUtils.isEmpty(sweepContent)) {
                    if (sweepContent.length() > 35) {
                        msg.description = subString(sweepContent, 35)+"...";
                    }else{
                        msg.description = sweepContent;
                    }
                }
                break;
            // 分享 微信 日常
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                webpageObj = new WXWebpageObject();
                webpageObj.webpageUrl = shareInfo.getShareUrl();
                msg = new WXMediaMessage(webpageObj);

                String noteTitle = "";

                if (shareInfo.getTitle() != null && !shareInfo.getTitle().isEmpty()) {
                    noteTitle = shareInfo.getTitle();
                }
                String noteContent = "来自豆花App，女性向创作社区";
                String noteTags = "";

                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    noteTags = shareInfo.getTags()[0];
                }
                if (shareInfo.getObject_type().equals("41")) {
                    String tag = "";
                    if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                        tag = "#" + shareInfo.getTags()[0] + "#";
                    }
                    if (!TextUtils.isEmpty(shareInfo.getTitle())) {
                        if (shareInfo.getTitle().length()>15){
                            noteTitle = subString(shareInfo.getTitle(), 15)+"...";
                        }else{
                            noteTitle = shareInfo.getTitle();
                        }
                    }else{
                        noteTitle = "我参与了豆花的"+tag+"话题";
                    }

                    if (!TextUtils.isEmpty(shareInfo.getDescription())) {
                        if (shareInfo.getDescription().length()>25){
                            noteContent = subString(shareInfo.getDescription(), 25)+"...";
                        }else{
                            noteContent = shareInfo.getDescription();
                        }
                    }else{
                        noteContent = "快来围观吧~";
                    }

                } else if (shareInfo.getObject_type().equals("42")) {
                    noteTitle = "【" + noteTags + "】" + noteTitle;
                    noteTitle = subString(noteTitle, 25);
                    if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                        noteContent = shareInfo.getDescription();
                    } else {
                        noteContent = "来自女性向创作社区豆花App的绘画作品";
                    }
                } else if (shareInfo.getObject_type().equals("43")) {
                    noteTitle = "【" + noteTags + "】" + noteTitle;
                    noteTitle = subString(noteTitle, 25);
                    if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                        noteContent = shareInfo.getDescription();
                    } else {
                        noteContent = "来自女性向创作社区豆花App的COS作品";
                    }
                }
                noteContent = subString(noteContent, 35);
                msg.title = noteTitle;
                msg.description = noteContent;

                if (shareInfo.getImagUrl() != null) {
                    bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());

                    if (bmp == null) {
                        bmp = FetchResourceUtil.fetchBitmap(
                                mContext.getResources(), R.drawable.new_icon);
                    }
                    if (bmp != null) {
                        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,
                                WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE,
                                true);
                        msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                    }
                }
                TTLog.d("tag", "wechat share ================================= succeed");
                break;
            //分享 微信 漫画
            case ShareBeansInfo.CARTOON_SHARE_FLAG:
                webpageObj = new WXWebpageObject();
                webpageObj.webpageUrl = shareInfo.getShareUrl();
                msg = new WXMediaMessage(webpageObj);

                String cartoonTitle = "豆花漫画看不停!";
                String cartoonContent = "来自豆花App，女性向创作社区";
                String cartoonTags = "";
                cartoonTitle = subString(cartoonTitle, 25);


                StringBuilder contentSb = new StringBuilder();
                contentSb.append("我在看《");
                contentSb.append(shareInfo.getTitle());
                contentSb.append("》");
                contentSb.append(shareInfo.getDescription());
                cartoonContent = contentSb.toString();

                if (!TextUtils.isEmpty(shareInfo.getTitle())) {
                    if (shareInfo.getTitle().length() > 15) {
                        msg.title = subString(shareInfo.getTitle(), 15)+"...";
                    }else{
                        msg.title = shareInfo.getTitle();
                    }
                }
                msg.description = "我最近在追的漫画，介绍给你";

                if (shareInfo.getImagUrl() != null) {
                    bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());

                    if (bmp == null) {
                        bmp = FetchResourceUtil.fetchBitmap(
                                mContext.getResources(), R.drawable.new_icon);
                    }
                    if (bmp != null) {
                        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,
                                WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE,
                                true);
                        msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                    }
                }
                break;
            default:
                break;
        }

        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.scene = SendMessageToWX.Req.WXSceneSession; // for wechat friends
        req.transaction = String.valueOf(System.currentTimeMillis());
        req.message = msg;
        boolean flag = wxAPI.sendReq(req);

    }

    // 朋友圈
    private void shareToPengyouquan() {
        WXEntryActivity.Companion.setShareInfo(shareInfo);
        if (wxAPI.getWXAppSupportAPI() < Constant.WXData.PENG_YOU_QUAN_MIN_VERSION_CODE) {
            Toast.makeText(mContext,
                    R.string.info_share_pengyouquan_version_too_low,
                    Toast.LENGTH_LONG).show();
            return;
        }
        String shareURL;
        if (shareInfo.getShareData() != null) {
            shareURL = shareInfo.getShareData().getShareUrl();
        } else {
            shareURL = shareInfo.getShareUrl();
        }
        if (shareURL == null) {
            shareURL = Constant.DOWN_URL_WX;
        }
        WXMediaMessage msg = null;
        WXTextObject textObj = null;
        switch (shareInfo.getFlag()) {
            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                Bitmap bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());
                if (bmp == null) {
                    bmp = FetchResourceUtil.fetchBitmap(mContext.getResources(),
                            R.drawable.new_icon);
                }
                WXWebpageObject webpageObj = new WXWebpageObject();
                webpageObj.webpageUrl = shareURL;

                msg = new WXMediaMessage(webpageObj);
                msg.title = shareInfo.getTitle();
                msg.description = shareInfo.getTitle();

                if (bmp != null) {
                    Bitmap thumbBmp = Bitmap
                            .createScaledBitmap(bmp, WXData.THUMB_WIDTH_SIZE,
                                    WXData.THUMB_HEIGHT_SIZE, true);
                    msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                }
                break;
            case ShareBeansInfo.PHOTO_SHARE_FLAG:

                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_SHAKE) {
                    // 初始化一个WXTextObject对象
                    textObj = new WXTextObject();
                    if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_FLAG) {
                        textObj.text = "妹子求评分！" + shareInfo.getImagUrl();
                    } else {
                        textObj.text = shareInfo.getImagUrl();
                    }
                    // 用WXTextObject对象初始化一个WXMediaMessage对象
                    msg = new WXMediaMessage();
                    msg.mediaObject = textObj;
                    if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_FLAG) {
                        msg.description = "妹子求评分";
                    }
                } else {
                    bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());
                    if (bmp == null) {
                        bmp = FetchResourceUtil.fetchBitmap(
                                mContext.getResources(), R.drawable.new_icon);
                    }
                    webpageObj = new WXWebpageObject();
                    webpageObj.webpageUrl = shareURL;
                    msg = new WXMediaMessage(webpageObj);
                    msg.title = "小心亮瞎你的狗眼...";
                    msg.description = shareInfo.getTitle();
                    if (bmp != null) {
                        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,
                                WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE,
                                true);
                        msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                    }
                }
                break;

            case ShareBeansInfo.WOED_SHARE_FlAG:
                textObj = new WXTextObject();
                textObj.text = " #豆花#" + shareInfo.getImagUrl() + "(分享自@豆花客户端"
                        + shareInfo.getShareUrl() + ")";
                msg = new WXMediaMessage();
                msg.mediaObject = textObj;
                msg.description = shareInfo.getTitle();

                break;
            // 分享 朋友圈 视频
            case ShareBeansInfo.VIDEO_SHARE_FLAG:
                WXVideoObject video = new WXVideoObject();
                video.videoUrl = shareURL;
                msg = new WXMediaMessage(video);

                msg.title = "《" + shareInfo.getShareData().getTitle() + "》来自豆花App";
                msg.description = "看完我再一次脑洞大开！";
                Bitmap thumb = BitmapFactory.decodeResource(
                        WeMediaApplication.applicationContext.getResources(),
                        R.drawable.new_icon);
                thumb = Bitmap.createScaledBitmap(thumb, WXData.THUMB_WIDTH_SIZE,
                        WXData.THUMB_HEIGHT_SIZE, true);
                msg.thumbData = WXUtil.bmpToByteArray(thumb, true);
                break;
            // 分享 朋友圈 话题
            case ShareBeansInfo.TOPIC_SHARE_FLAG:
                webpageObj = new WXWebpageObject();
                webpageObj.webpageUrl = shareURL;
                msg = new WXMediaMessage(webpageObj);

                if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                    msg.title = subString(shareInfo.getTitle() + " " + shareInfo.getDescription(), 25);
                } else {
                    msg.title = subString(shareInfo.getTitle(), 25);
                }
                msg.description = "致我碎成粉末的三观……";
                if (shareInfo.getImagUrl() != null) {
                    bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());

                    if (bmp == null) {
                        bmp = FetchResourceUtil.fetchBitmap(
                                mContext.getResources(), R.drawable.new_icon);
                    }
                    if (bmp != null) {
                        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,
                                WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE,
                                true);
                        msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                    }
                }
                break;
            // 分享 朋友圈 小说
            case ShareBeansInfo.NOVEL_SHARE_FLAG:
                String url = Constant.LOGO_URL;
                if (!TextUtils.isEmpty(shareInfo.getImagUrl())) {
                    url = shareInfo.getImagUrl();
                }
                url = Constant.changeUrlHost(url);
                Glide.with(WeMediaApplication.applicationContext).asBitmap().load(url).into(new SimpleTarget<Bitmap>() {
                    @Override
                    public void onResourceReady(@NonNull Bitmap logoBitmap, @Nullable Transition<? super Bitmap> transition) {
                        if (logoBitmap == null) {
                            logoBitmap = FetchResourceUtil.fetchBitmap(mContext.getResources(),
                                    R.drawable.new_icon);
                        }
                        WXWebpageObject novelpageObj = new WXWebpageObject();
                        novelpageObj.webpageUrl = shareInfo.getShareData().getShareUrl();
                        WXMediaMessage msg = new WXMediaMessage(novelpageObj);
                        StringBuilder showTitle = new StringBuilder();
                        showTitle.append(shareInfo.getTitle());
                        if (!TextUtils.isEmpty(shareInfo.getShartText())) {
                            showTitle.append(":");
                            showTitle.append(shareInfo.getShartText());
                        }
                        if (showTitle.toString().length() > 25) {
                            msg.title = subString(showTitle.toString(), 25)+"...";
                        }else{
                            msg.title = showTitle.toString();
                        }
                        msg.description = "这篇小说太赞了！（豆花，女性向创作社区）";
                        if (logoBitmap != null) {
                            Bitmap thumbBmp = Bitmap.createScaledBitmap(logoBitmap, WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE, true);
                            msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                        }
                        SendMessageToWX.Req req = new SendMessageToWX.Req();
                        req.scene = SendMessageToWX.Req.WXSceneTimeline; // for pengyou quan
                        req.transaction = String.valueOf(System.currentTimeMillis());
                        req.message = msg;
                        wxAPI.sendReq(req);
                    }
                });

                return;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:
                Bitmap rankBitmap = FetchResourceUtil.fetchBitmap(mContext.getResources(), R.drawable.new_icon);

                WXWebpageObject rankpageObj = new WXWebpageObject();
                rankpageObj.webpageUrl = shareChannel(shareInfo.getShareUrl(), Constant.ShareChannel.pengyouquan);
                msg = new WXMediaMessage(rankpageObj);
                msg.title = "腐化度测试";
//			msg.description =shareInfo.getShartText() ;
                msg.description = shareChannel(shareInfo.getShartText(), Constant.ShareChannel.pengyouquan);
                if (rankBitmap != null) {
                    Bitmap thumbBmp = Bitmap.createScaledBitmap(rankBitmap, WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE, true);
                    msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                }
                break;
            // 分享 朋友圈 文评
            case ShareBeansInfo.SWEEP_SHARE_FLAG:
                WXWebpageObject sweeppageObj = new WXWebpageObject();
                sweeppageObj.webpageUrl = shareInfo.getShareUrl();
                SweepBean sweepBean = shareInfo.getShareData().getSweep();
                String sweepTitle = "";
                String sweepTag = "";
                String sweepLevel = "";
                String sweepContent = "";
                String[] tags = sweepBean.getTag_list().split("\\s+");
                NovelBean novelBean = shareInfo.getNovelBean();
                if (tags != null && tags.length > 0) {

                    sweepTag = tags[0];
                } else sweepTag = "";
                sweepLevel = UIUtil.showStarLevel(Integer.valueOf(sweepBean.getStar()));
                if (sweepBean.getReview() != null) {
                    sweepContent = sweepBean.getReview();
                }
//                sweepTitle = "【" + sweepLevel + "小说】" + novelBean.getTitle() + "by" + novelBean.getAuthor() + "/" + sweepTag;
//                msg.title = subString(sweepTitle, 25);
//                msg.description = subString(sweepContent, 35);
                msg = new WXMediaMessage(sweeppageObj);
                String sTitle ="";
                if (!TextUtils.isEmpty(novelBean.getTitle())) {
                    sTitle = "【豆花文评】"+novelBean.getTitle();
                }else{
                    sTitle = "【豆花文评】";
                }
                if (sTitle.length() > 25) {
                    msg.title = subString(sTitle, 25);
                }else{
                    msg.title = sTitle;
                }
                break;
            // 分享 朋友圈 日常
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                webpageObj = new WXWebpageObject();
                webpageObj.webpageUrl = shareInfo.getShareUrl();
                msg = new WXMediaMessage(webpageObj);
                String wxTag = "";

                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    wxTag = "【" + shareInfo.getTags()[0] + "】";
                }

                if (shareInfo.getObject_type().equals("41")) {
                    String sinaTag = "";
                    String noteTitle = "";
                    String noteContent = "";
                    if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                        sinaTag = "#" + shareInfo.getTags()[0] + "#";
                    }
                    if (shareInfo.getDescription() != null) {
                        if (shareInfo.getDescription().length()>25){
                            noteContent = subString(shareInfo.getDescription(), 25) + "...";
                        }else{
                            noteContent = shareInfo.getDescription() ;
                        }
                    }
                    if (shareInfo.getTitle() != null) {
                        if (shareInfo.getTitle().length()>25){
                            noteTitle = subString(shareInfo.getTitle(), 25) + "...";
                        }else{
                            noteTitle = shareInfo.getTitle() ;
                        }
                    }

                    if (!TextUtils.isEmpty(noteTitle)) { //有标题
                        msg.title = sinaTag+noteTitle;
                    }else{
                        if (!TextUtils.isEmpty(noteContent)) { //有正文
                            msg.title = sinaTag+noteContent;
                        }else{
                            msg.title = "我参与了豆花的"+sinaTag+"话题，快来围观吧~";
                        }
                    }
                } else if (shareInfo.getObject_type().equals("42")) {
                    if (shareInfo.getTitle() != null && !shareInfo.getTitle().isEmpty()) {
                        msg.title = wxTag + shareInfo.getTitle();
                    } else if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                        msg.title = wxTag + shareInfo.getDescription();
                    } else {
                        msg.title = wxTag + "来自女性向创作社区豆花App的绘画作品";
                    }
                } else if (shareInfo.getObject_type().equals("43")) {
                    if (shareInfo.getTitle() != null && !shareInfo.getTitle().isEmpty()) {
                        msg.title = wxTag + shareInfo.getTitle();
                    } else if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                        msg.title = wxTag + shareInfo.getDescription();
                    } else {
                        msg.title = wxTag + "来自女性向创作社区豆花App的COS作品";
                    }
                }

                msg.title = subString(msg.title, 25);

                if (shareInfo.getImagUrl() != null) {
                    bmp = ImageManager.getCacheBitMap(shareInfo.getImagUrl());

                    if (bmp == null) {
                        bmp = FetchResourceUtil.fetchBitmap(
                                mContext.getResources(), R.drawable.new_icon);
                    }
                    if (bmp != null) {
                        Bitmap thumbBmp = Bitmap.createScaledBitmap(bmp,
                                WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE,
                                true);
                        msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                    }
                }
                break;
            // 分享 朋友圈 漫画
            case ShareBeansInfo.CARTOON_SHARE_FLAG:
                Bitmap cartoonBitmap = FetchResourceUtil.fetchBitmap(mContext.getResources(), R.drawable.new_icon);

                WXWebpageObject cartoonpageObj = new WXWebpageObject();
                if (!TextUtils.isEmpty(shareInfo.getShareUrl())) {
                    cartoonpageObj.webpageUrl = shareInfo.getShareUrl();
                }else{
                    cartoonpageObj.webpageUrl = shareURL;
                }

                msg = new WXMediaMessage(cartoonpageObj);
                StringBuilder title = new StringBuilder();
                title.append("《");
                title.append(shareInfo.getTitle());
                title.append("》");
                if (!TextUtils.isEmpty(shareInfo.getDescription())) {
                    title.append(shareInfo.getDescription());
                }
                if (title.length() > 25) {
                    msg.title = subString(title.toString(), 25)+"...";
                }else{
                    msg.title = title.toString();
                }
//                msg.title = subString(title, 25);
//                msg.description = subString(content, 35);
                if (cartoonBitmap != null) {
                    Bitmap thumbBmp = Bitmap.createScaledBitmap(cartoonBitmap, WXData.THUMB_WIDTH_SIZE, WXData.THUMB_HEIGHT_SIZE, true);
                    msg.thumbData = WXUtil.bmpToByteArray(thumbBmp, true);
                }
                break;
            default:
                break;
        }

        SendMessageToWX.Req req = new SendMessageToWX.Req();
        req.scene = SendMessageToWX.Req.WXSceneTimeline; // for pengyou quan
        req.transaction = String.valueOf(System.currentTimeMillis());
        req.message = msg;
        wxAPI.sendReq(req);
    }

    private void shareToMessage() {
        String smsBody = "";
        switch (shareInfo.getFlag()) {

            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                smsBody = "土豪，我在豆花里面发现了一篇劲爆的文章《"
                        + shareInfo.getTitle()
                        + "》，赶紧立马查看："
                        + shareInfo.getShareUrl()
                        + "。我们在玩豆花，你还不来？快点击下载一起玩吧！" + Constant.DOWN_URL_DX;
                break;
            case ShareBeansInfo.PHOTO_SHARE_FLAG:
                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_FLAG) {
                    smsBody = "刚在豆花撸的妹子" + shareInfo.getImagUrl()
                            + "你觉得多少分？快下载豆花，一起来撸妹子";
                } else {
                    smsBody = "刚在豆花里面发现的一张图，很有意思！你也下载豆花一起玩吧！里面有好多宅腐劲爆内容。"
                            + shareInfo.getImagUrl();
                }

                break;

            case ShareBeansInfo.WOED_SHARE_FlAG:
                smsBody = "我在豆花里分享了一个故事" + shareInfo.getImagUrl() + "(快进来给我点赞吧！"
                        + shareInfo.getShareUrl() + ")";
                break;

            case ShareBeansInfo.VIDEO_SHARE_FLAG:
                smsBody = "*' ∀ `*)我在豆花App发现了这个视频【" + shareInfo.getTitle() + "】，觉得非常适合你看！视频地址" + shareInfo.getShareData().getPlay_url();

            case ShareBeansInfo.TOPIC_SHARE_FLAG:
                smsBody = "发现了一个超级好玩的话题《" + shareInfo.getTitle() + "》查看全文：" + shareInfo.shareUrl + " 豆花，女性向创作社区。好多资源么么哒！下载完我们一起玩吧！";
                break;
            case ShareBeansInfo.NOVEL_SHARE_FLAG:
                smsBody = "我在豆花看了一篇非常好的小说：《" + shareInfo.getTitle() + "》" + shareInfo.getShareData().getShareUrl() + "不分享对不起你和作者！豆花，女性向创作社区，资源多多，快去下载App吧！";
                break;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:
//			smsBody=shareInfo.getShartText()+"查看"+shareInfo.getShareUrl();
                smsBody = shareChannel(shareInfo.getShartText() + "查看" + shareInfo.getShareUrl(), Constant.ShareChannel.other);
                break;
            case ShareBeansInfo.SWEEP_SHARE_FLAG:

                NovelBean novelBean = shareInfo.getNovelBean();
                if (novelBean == null) {
                    smsBody = "#豆花文评# 《" + shareInfo.getTitle() + "》" + subString(shareInfo.getDescription(), 30) + "...阅读全文"
                            + shareInfo.shareUrl + " 女性向创作社区@腐女文评组";
                } else {
                    String tag = "";
                    HomeTopBean bean = shareInfo.getShareData();
                    if (bean != null && bean.getSweep() != null) {
                        String tagList = bean.getSweep().getTag_list();
                        tag = " " + tagList;
                    }
                    float star = Float.valueOf(novelBean.getStar());
                    String level = UIUtil.showStarLevel((int) star);
                    smsBody = "#豆花文评# " + level + "《" + shareInfo.getTitle() + "》 作者：" + novelBean.getAuthor() + tag + " 点击查看文评："
                            + shareInfo.shareUrl;
                }

                break;
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                smsBody = "我在豆花里分享了一个日常" + shareInfo.getImagUrl() + "(快进来给我点赞吧！" + shareInfo.getShareUrl() + ")";
                break;
            default:
                break;
        }
        Uri smsToUri = Uri.parse("smsto:");
        Intent intent = new Intent(Intent.ACTION_SENDTO, smsToUri);
        intent.putExtra("sms_body", smsBody);
        mContext.startActivity(intent);
    }

    private void shareToEmail() {
        String shareText = "";
        String title = "";
        switch (shareInfo.getFlag()) {

            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                shareText = "我发现了一个劲爆的内容，快来看。我们都在玩豆花，你也赶紧下载一起玩：" + Constant.DOWN_URL_YJ;
                title = shareInfo.getTitle();
                break;
            case ShareBeansInfo.PHOTO_SHARE_FLAG:
                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_SHAKE) {
                    shareText = "这个妹子还不错吧，最近迷上了豆花的撸一撸妹子，你也下载来玩呗！很容易上瘾~!"
                            + shareInfo.getImagUrl();
                    title = "给你分享了个不错的妹子！";
                } else {

                    shareText = "你的好友邀请您下载豆花，里面充满有趣劲爆的宅腐内容！"
                            + shareInfo.getImagUrl();
                    title = "我发现了一张非常有意思的图，快进来看看！";
                }
                break;
            case ShareBeansInfo.WOED_SHARE_FlAG:
                shareText = " #豆花#" + shareInfo.getImagUrl() + "(分享自@豆花客户端"
                        + shareInfo.getShareUrl() + ")";
                title = "我发现了一篇有意思的文章，快进来看看！";
                break;

            case ShareBeansInfo.VIDEO_SHARE_FLAG:
//			shareText = "【"+shareInfo.getTitle()+"】这个视频你一定要看！都快把我笑趴了……视频地址"
//					+ shareInfo.getShareData().getPlay_url();
                shareText = "我在App【豆花】看到一个很棒的视频《" + shareInfo.getTitle() + "》！地址：" + shareInfo.getShareData().getPlay_url() + " 女性向创作社区@豆花";

                title = "主题：非常无节操有亮点内涵的搞笑视频";
                break;
            case ShareBeansInfo.TOPIC_SHARE_FLAG:
//			shareText = "《"+shareInfo.getTitle()+"》一定是我打开的方式不对！（哈哈打滚ing）";
                shareText = "《" + shareInfo.getTitle() + "》" + "查看详细：" + shareInfo.getShareUrl() + " 女性向创作社区@豆花";
                title = "我快被这个话题逗死了";
                break;
            case ShareBeansInfo.NOVEL_SHARE_FLAG:
//			shareText ="《"+shareInfo.getTitle()+"》（来自：豆花，女性向创作社区）"+subString(shareInfo.getShareData().getDes(), 30)+"下载地址"+shareInfo.getShareData().getShareUrl();
                shareText = "#豆花文评# 《" + shareInfo.getTitle() + "》" + subString(shareInfo.getShareData().getDes(), 30) + "...阅读全文"
                        + shareInfo.getShareData().getShareUrl() + " 女性向创作社区@腐女文评组";

                title = "不分享这个就太对不起你了！";
                break;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:
//			shareText=shareInfo.getShartText()+"查看"+shareInfo.getShareUrl();
                shareText = shareChannel(shareInfo.getShartText() + "查看" + shareInfo.getShareUrl(), Constant.ShareChannel.other);
                break;
            case ShareBeansInfo.SWEEP_SHARE_FLAG:
                shareText = "#豆花文评# 《" + shareInfo.getTitle() + "》" + subString(shareInfo.getDescription(), 30) + "...阅读全文"
                        + shareInfo.shareUrl + " 女性向创作社区@腐女文评组";
                break;
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                shareText = "我在豆花里分享了一个日常" + shareInfo.getImagUrl() + "(快进来给我点赞吧！" + shareInfo.getShareUrl() + ")";
                break;
            default:
                break;
        }

        try {
            String[] emailReciver = new String[]{"xxxx@qq.com", "yyy@xx.com"};
            Intent intent = new Intent(Intent.ACTION_SENDTO);
            // intent.setType("message/rfc882");
            // 设置邮件默认地址
            intent.putExtra(android.content.Intent.EXTRA_EMAIL, emailReciver);
            intent.putExtra(Intent.EXTRA_SUBJECT, title);
            intent.putExtra(Intent.EXTRA_TEXT, shareText);
            mContext.startActivity(intent);

        } catch (ActivityNotFoundException e) {
            e.printStackTrace();
            Toast.makeText(mContext,
                    mContext.getString(R.string.info_email_start_failed),
                    Toast.LENGTH_LONG).show();
        }
    }

    private void shareToSystemMore() {
        String shareText = "";
        String title = "";
        switch (shareInfo.getFlag()) {

            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                TTLog.s("ShareTopPopupWindow===1");
                shareText = mContext
                        .getString(R.string.common_share_tag_prefix_start)
                        + shareInfo.getArticleAuthor()
                        + mContext.getString(R.string.common_share_tag_prefix_end)
                        + "《"
                        + shareInfo.getTitle()
                        + "》 "
                        + mContext
                        .getString(R.string.common_share_tag_prefix_address)
                        + shareInfo.getShareUrl()
                        + " "
                        + "@"
                        + mContext.getString(R.string.app_name);
                title = mContext.getString(R.string.share_article_title);
                break;
            case ShareBeansInfo.PHOTO_SHARE_FLAG:
                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_SHAKE) {
                    shareText = "这个妹子还不错吧，最近迷上了豆花的撸一撸妹子，你也下载来玩呗！很容易上瘾~!"
                            + shareInfo.getImagUrl();
                    title = "给你分享了个不错的妹子！";
                } else {

                    shareText = "你的好友邀请您下载豆花，里面充满有趣劲爆的宅腐内容！"
                            + shareInfo.getImagUrl();
                    title = "我发现了一张非常有意思的图，快进来看看！";
                }
                break;
            case ShareBeansInfo.WOED_SHARE_FlAG:
                shareText = " #豆花#" + shareInfo.getImagUrl() + "(分享自@豆花客户端"
                        + shareInfo.getShareUrl() + ")";
                title = "我发现了一篇有意思的文章，快进来看看！";
                break;

            case ShareBeansInfo.VIDEO_SHARE_FLAG:
//			shareText = "【"+shareInfo.getTitle()+"】这个视频你一定要看！都快把我笑趴了……视频地址"
//					+ shareInfo.getShareData().getPlay_url();
                shareText = "我在App【豆花】看到一个很棒的视频《" + shareInfo.getTitle() + "》！地址：" + shareInfo.getShareData().getPlay_url() + " 女性向创作社区@豆花";

                title = "主题：非常无节操有亮点内涵的搞笑视频";
                break;
            case ShareBeansInfo.TOPIC_SHARE_FLAG:
//			shareText = "《"+shareInfo.getTitle()+"》一定是我打开的方式不对！（哈哈打滚ing）";
                shareText = "《" + shareInfo.getTitle() + "》" + "查看详细：" + shareInfo.getShareUrl() + " 女性向创作社区@豆花";
                title = "我快被这个话题逗死了";
                break;
            case ShareBeansInfo.NOVEL_SHARE_FLAG:
//			shareText ="《"+shareInfo.getTitle()+"》（来自：豆花，女性向创作社区）"+subString(shareInfo.getShareData().getDes(), 30)+"下载地址"+shareInfo.getShareData().getShareUrl();
                shareText = "#豆花文评# 《" + shareInfo.getTitle() + "》" + subString(shareInfo.getShareData().getDes(), 30) + "...阅读全文"
                        + shareInfo.getShareData().getShareUrl() + " 女性向创作社区@腐女文评组";

                title = "不分享这个就太对不起你了！";
                break;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:
                shareText = shareInfo.getShartText() + "查看" + shareInfo.getShareUrl();
                shareText = shareChannel(shareInfo.getShartText() + "查看" + shareInfo.getShareUrl(), Constant.ShareChannel.other);
                break;
            case ShareBeansInfo.SWEEP_SHARE_FLAG:
                shareText = "#豆花文评# 《" + shareInfo.getTitle() + "》" + subString(shareInfo.getDescription(), 30) + "...阅读全文"
                        + shareInfo.shareUrl + " 女性向创作社区@腐女文评组";
                break;
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                shareText = "我在豆花里分享了一个日常" + shareInfo.getImagUrl() + "(快进来给我点赞吧！" + shareInfo.getShareUrl() + ")";
                break;
            default:
                break;

        }
        TTLog.s("ShareTopPopupWindow===3" + title + "==" + shareText);
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.addCategory("android.intent.category.DEFAULT");
        intent.setType("text/plain");
        intent.putExtra(Intent.EXTRA_SUBJECT, title);
        intent.putExtra(Intent.EXTRA_TEXT, shareText);
        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        mContext.startActivity(Intent.createChooser(intent,
                mContext.getString(R.string.share_title)));

    }

    // QQ空间
    private void shareQQSpace() {
        String shareURL = "";
        if (shareInfo.getShareData() != null) {
            shareURL = shareInfo.getShareData().getShareUrl();
        } else {
            shareURL = shareInfo.getShareUrl();
        }
        if (shareURL == null) {
            shareURL = Constant.DOWN_URL_WB;
        }
        Bundle params = new Bundle();
        String title = "";
        String content = "";
        String shareUrl = "";
        ArrayList<String> imgs = new ArrayList<>();
        switch (shareInfo.getFlag()) {
            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                title = shareInfo.getTitle();
                imgs.add(shareInfo.getImagUrl());
                shareUrl = shareInfo.getShareUrl();
                break;
            case ShareBeansInfo.PHOTO_SHARE_FLAG:
                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_SHAKE) {
                    title = "给你分享了个不错的妹子！";
                    imgs.add(shareInfo.getImagUrl());
                    shareUrl = shareInfo.getImagUrl();
                    content = "这个妹子还不错吧，最近迷上了豆花的撸一撸妹子，你也下载来玩呗！很容易上瘾~!"
                            + shareInfo.getImagUrl();
                } else {
                    title = "我发现了一张非常有意思的图，快进来看看！";
                    imgs.add(shareInfo.getImagUrl());
                    shareUrl = shareInfo.getImagUrl();
                    content = "我在#豆花#里面发现这张图屌炸天了！更多宅腐内容尽在豆花，你们也快来下载吧！"
                            + shareInfo.getImagUrl();
                }
                break;
            case ShareBeansInfo.WOED_SHARE_FlAG:
                title = shareInfo.getTitle();
                imgs.add(Constant.SHARE_IMAG_URL);
                shareUrl = shareInfo.getShareUrl();
                content = shareInfo.getImagUrl();
                break;
            case ShareBeansInfo.VIDEO_SHARE_FLAG:
                title = shareInfo.getShareData().getTitle();
                shareUrl = shareInfo.getShareData().getShareUrl();
                content = "哇，画面好美你敢不敢看？豆花，女性向创作社区，里面都是腐妹子最爱的内容哦！";
                if (shareInfo.getShareData().getImages().length > 0)
                    imgs.add(shareInfo.getShareData().getImages()[0].getImgUrl());
                else
                    imgs.add(Constant.SHARE_IMAG_URL);
                break;

            // 分享 QQ空间 话题
            case ShareBeansInfo.TOPIC_SHARE_FLAG:
                title = subString(shareInfo.getTitle(), 20);
                imgs.add(shareInfo.getImagUrl());
                shareUrl = shareInfo.getShareUrl();
                content = subString(shareInfo.getDescription(), 30) + "【分享自女性向创作社区豆花App】";
                break;
            // 分享 QQ空间 小说
            case ShareBeansInfo.NOVEL_SHARE_FLAG:
                title = subString("《" + shareInfo.getTitle() + "》", 20);
                if (!TextUtil.isEmpty(shareInfo.getImagUrl())) {
                    imgs.add(shareInfo.getImagUrl());
                }else{
                    imgs.add(Constant.LOGO_URL);
                }
                shareUrl = shareInfo.getShareData().getShareUrl();
                // 获取标签
                String[] tagStrings = new String[3];
                String tagsString = "#";
                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    tagStrings = shareInfo.getTags();
                    for (int i = 0; i < ((tagStrings.length < 3) ? tagStrings.length : 3); i++) {
                        tagsString += (tagStrings[i] + "##");
                    }
                    if (tagsString != null && tagsString.length() > 0) {
                        tagsString = tagsString.substring(0, tagsString.length() - 1);
                    }
                }
                content = "我最近在#豆花#读《"+shareInfo.getTitle()+"》"+tagsString+"，觉得不错，介绍给你们";
                break;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:
                title = "腐化度测试";
                imgs.add(Constant.LOGO_URL);
//			shareUrl = shareInfo.getShareUrl();
                shareUrl = shareChannel(shareInfo.getShareUrl(), Constant.ShareChannel.qZone);
                content = shareInfo.getShartText() + "豆花地址" + Constant.DOWN_URL_QQ;
                break;

            // 分享 QQ空间 文评
            case ShareBeansInfo.SWEEP_SHARE_FLAG:

                imgs.add(Constant.LOGO_URL);
                shareUrl = shareInfo.getShareUrl();
                NovelBean novelBean = shareInfo.getNovelBean();
                if (novelBean != null) {
                    float star = Float.valueOf(novelBean.getStar());
                    String level = UIUtil.showStarLevel((int) star);
                    if (!isStringEmpty(shareInfo.getTitle())) {
                        title = subString(shareInfo.getTitle(), 20);
                    } else {
                        title = "快来加入豆花";
                    }
                    // 获取标签
                    String tagsSweepString = "#";
                    if (shareInfo.getShareData() != null && shareInfo.getShareData().getSweep() != null) {
                        SweepBean sweepBean = shareInfo.getShareData().getSweep();
                        String[] tagSweepStrings = sweepBean.getTag_list().split("\\s+");
                        for (int i = 0; i < ((tagSweepStrings.length < 3) ? tagSweepStrings.length : 3); i++) {
                            tagsSweepString += (tagSweepStrings[i] + "##");
                        }
                        if (tagsSweepString != null && tagsSweepString.length() > 0) {
                            tagsSweepString = tagsSweepString.substring(0, tagsSweepString.length() - 1);
                        }
                        String sweepContent = sweepBean.getReview();
                        String showContent = "";
                        if (!TextUtils.isEmpty(sweepContent)){
                            if (sweepContent.length() > 60) {
                                showContent = subString(sweepContent, 60) + "...";
                            }else{
                                showContent = sweepContent;
                            }
                        }
                        content = "#豆花文评#"  + novelBean.getTitle() + "，"  + tagsSweepString + "，" + showContent
                                + "文评详情：" + shareURL;
                    }

                } else {
                    title = shareInfo.getTitle();
                    content = shareInfo.getShartText() + "豆花地址" + Constant.DOWN_URL_QQ;
                }
                break;
            // 分享 QQ空间 日常
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                final String SINA_SHARE_FOOT = " 下载：" + Constant.DOWN_URL_WB;
                int object_type = Integer.parseInt(shareInfo.getObject_type());
                String tag = "";
                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    tag = "#" + shareInfo.getTags()[0] + "#";
                }
                switch (object_type) {
                    case Constant.OBJECT_TYPE_NOTE:
                        if (!isStringEmpty(shareInfo.getTitle())) {
                            title = subString(shareInfo.getTitle(), 20);
                        } else {
                            title = "快来加入豆花";
                        }
                        String noteTitle = "";
                        String noteContent = "";
                        if (shareInfo.getTitle() != null) {
                            noteTitle = shareInfo.getTitle();
                        }

                        if (shareInfo.getDescription() != null) {
                            if (shareInfo.getDescription().length()>60){
                                noteContent = subString(shareInfo.getDescription(), 60) + "...";
                            }else{
                                noteContent = shareInfo.getDescription() ;
                            }
                        }
                        if (!TextUtils.isEmpty(noteTitle)) { //有标题
                            if (!TextUtils.isEmpty(noteContent)) { //有正文
                                content = tag+noteTitle+"："+noteContent+"(围观请戳："+shareInfo.getShareUrl() + SINA_SHARE_FOOT + ")";
                            }else{
                                content = tag+noteTitle+"(围观请戳："+shareInfo.getShareUrl() + SINA_SHARE_FOOT + ")";
                            }
                        }else{
                            if (!TextUtils.isEmpty(noteContent)) { //有正文
                                content = "我参与了豆花的"+tag+"话题："+noteContent+"(围观请戳："+shareInfo.getShareUrl()  + ")";
                            }else{
                                content = "我参与了豆花的"+tag+"话题，围观请戳："+shareInfo.getShareUrl() ;
                            }
                        }
                        break;
                    // 分享 QQ空间 绘画
                    case Constant.OBJECT_TYPE_DRAW:
                        if (!isStringEmpty(shareInfo.getTitle())) {
                            title = subString(tag + shareInfo.getTitle(), 20);
                        } else {
                            title = "豆花App，女性向创作社区";
                        }
                        if (!isStringEmpty(shareInfo.getDescription())) {
                            content = subString(shareInfo.getDescription(), 30) + "【分享自女性向创作社区豆花App】";
                        } else {
                            content = "画师“" + shareInfo.getArticleAuthor() + "”作品 【分享自女性向创作社区豆花App】";
                        }
                        break;
                    // 分享 QQ空间 COS
                    case Constant.OBJECT_TYPE_COS:
                        if (!isStringEmpty(shareInfo.getTitle())) {
                            title = subString(tag + shareInfo.getTitle(), 20);
                        } else {
                            title = "豆花App，女性向创作社区";
                        }
                        if (!isStringEmpty(shareInfo.getDescription())) {
                            content = subString(shareInfo.getDescription(), 30) + "【分享自女性向创作社区豆花App】";
                        } else {
                            content = "“" + shareInfo.getArticleAuthor() + "”的cos作品 【分享自女性向创作社区豆花App】";
                        }
                        break;
                }
                if (shareInfo.getImagUrl() != null) {
                    imgs.add(shareInfo.getImagUrl());
                }
                shareUrl = shareInfo.getShareUrl();

                break;
            // 分享 qq空间 漫画
            case ShareBeansInfo.CARTOON_SHARE_FLAG:
                title = "豆花漫画看不停!";

                String[] tStrings = new String[3];
                String tString = "#";
                if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                    tStrings = shareInfo.getTags();
                    for (int i = 0; i < ((tStrings.length < 3) ? tStrings.length : 3); i++) {
                        tString += (tStrings[i] + "##");
                    }
                    if (tString != null && tString.length() > 0) {
                        tString = tString.substring(0, tString.length() - 1);
                    }
                }
                StringBuilder contentSb = new StringBuilder();
                contentSb.append("我最近在#豆花#追《");
                contentSb.append(shareInfo.getTitle());
                contentSb.append("》");
                contentSb.append(tString);
                contentSb.append("，超好看，介绍给你");
                contentSb.append(shareInfo.getShareUrl());
                content = subString(contentSb.toString(), 35);
                shareUrl = shareInfo.getShareUrl();
                break;
            default:
                break;

        }
        params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE,
                QzoneShare.SHARE_TO_QZONE_TYPE_NO_TYPE);
        params.putString(QQShare.SHARE_TO_QQ_TITLE, title);// 必填
        params.putString(QQShare.SHARE_TO_QQ_SUMMARY, content);// 选填
        params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, shareUrl);// 必填
        params.putStringArrayList(QQShare.SHARE_TO_QQ_IMAGE_URL, imgs);
        QQService.getInstance().shareToQZone(mContext, params,
                new IUiListener() {

                    @Override
                    public void onError(UiError arg0) {
                        TTLog.s(arg0.errorCode + ":::::" + arg0.errorMessage);
                    }

                    @Override
                    public void onComplete(Object arg0) {
                        if (shareInfo!=null && shareInfo.getId() != null && shareInfo.getShareData() != null) {
                                HomeMainServices.shareStatistics(mContext,
                                        String.valueOf(shareInfo.getSocial_type()),
                                        shareInfo.getShareData().getObject_type(),shareInfo.getId(),shareInfo.shareUrl);
                        }
                    }

                    @Override
                    public void onCancel() {
                    }
                });

    }

    public void shareQQ(final ShareBeansInfo shareInfo) {
        String title = "";
        String content = "";
        String shareUrl = "";
        String imageUrl = "";
        switch (shareInfo.getFlag()) {
            case ShareBeansInfo.AETICLE_SHARE_FLAG:
                content = "土豪，我在豆花里面发现了一篇劲爆的文章《" + shareInfo.getTitle() + "》";
                title = shareInfo.getTitle();
                shareUrl = shareInfo.getShareUrl();
                imageUrl = shareInfo.getImagUrl();
                break;
            case ShareBeansInfo.PHOTO_SHARE_FLAG:
                if (shareInfo.getPhotoFlag() == ShareBeansInfo.PHOTO_SHARE_SHAKE) {
                    title = "给你分享了个不错的妹子！";
                    shareUrl = shareInfo.getImagUrl();
                    content = "这个妹子还不错吧，最近迷上了豆花的撸一撸妹子，你也下载来玩呗！很容易上瘾~!"
                            + shareInfo.getImagUrl();
                    imageUrl = shareInfo.getImagUrl();
                } else {
                    title = "我发现了一张非常有意思的图，快进来看看！";
                    shareUrl = shareInfo.getImagUrl();
                    content = "我在#豆花#里面发现这张图屌炸天了！更多宅腐内容尽在豆花，你们也快来下载吧！"
                            + shareInfo.getImagUrl();
                    imageUrl = shareInfo.getImagUrl();
                }
                break;
            case ShareBeansInfo.WOED_SHARE_FlAG:
                content = shareInfo.getImagUrl();
                title = shareInfo.getTitle();
                shareUrl = shareInfo.getShareUrl();
                imageUrl = shareInfo.getShareUrl();
                break;
            // 分享 QQ 视频
            case ShareBeansInfo.VIDEO_SHARE_FLAG:
                title = shareInfo.getShareData().getTitle();
                shareUrl = shareInfo.getShareData().getShareUrl();
                content = "我在豆花App发现了一个好看的视频";
                if (shareInfo.getShareData().getImages().length > 0)
                    imageUrl = shareInfo.getShareData().getImages()[0].getImgUrl();
                else
                    imageUrl = Constant.SHARE_IMAG_URL;
                break;
            // 分享 QQ 话题
            case ShareBeansInfo.TOPIC_SHARE_FLAG:

                title = subString(shareInfo.getTitle(), 18);
                imageUrl = shareInfo.getImagUrl();
                shareUrl = shareInfo.getShareUrl();
                content = subString(shareInfo.getDescription(), 25);
                break;
            // 分享 QQ 小说
            case ShareBeansInfo.NOVEL_SHARE_FLAG:
                if (!TextUtils.isEmpty(shareInfo.getTitle())){
                    if (shareInfo.getTitle().length() > 15) {
                        title = subString(shareInfo.getTitle(), 15)+"...";
                    }else{
                        title = shareInfo.getTitle();
                    }
                }
                if (!TextUtils.isEmpty(shareInfo.getShartText())) {
                    if (shareInfo.getShartText().length() > 25) {
                        content = subString(shareInfo.getShartText(), 25)+"...";
                    }else{
                        content = shareInfo.getShartText();
                    }
                }else{
                    content = "我最近在读的小说，介绍给你";
                }
                if (!TextUtil.isEmpty(shareInfo.getImagUrl())) {
                    imageUrl = shareInfo.getImagUrl();
                }else{
                    imageUrl = Constant.LOGO_URL;
                }
                shareUrl = shareInfo.getShareData().getShareUrl();
                break;
            case ShareBeansInfo.RANK_SORCE_SHARE_FLAG:

                title = "腐化度测试";
                imageUrl = Constant.DOWN_URL_QQ;
//			shareUrl = shareInfo.getShareUrl();
                shareUrl = shareChannel(shareInfo.getShareUrl(), Constant.ShareChannel.qq);
                content = shareInfo.getShartText() + "豆花" + Constant.DOWN_URL_QQ;
                break;
            // 分享 QQ 文评
            case ShareBeansInfo.SWEEP_SHARE_FLAG:

                if (shareInfo.getShareData() != null && shareInfo.getShareData().getSweep() != null) {
                    SweepBean sweepBean = shareInfo.getShareData().getSweep();
                    String sweepTag = "";
                    String sweepLevel = "";
                    String sweepContent = "";


                    String[] tags = sweepBean.getTag_list().split("\\s+");
                    if (tags != null && tags.length > 0) {
                        sweepTag = "【" + tags[0] + "】";
                    } else sweepTag = "";
                    sweepContent = sweepBean.getReview();
                    title = shareInfo.getTitle();
                    imageUrl = Constant.DOWN_URL_QQ;
                    shareUrl = shareInfo.getShareUrl();
                    if (!TextUtils.isEmpty(sweepContent)) {
                        if (sweepContent.length() > 25) {
                            content = subString(sweepContent, 25)+"...";
                        }else{
                            content = sweepContent;
                        }
                    }
                }


                break;
            // 分享 QQ 日常 绘画 COS
            case ShareBeansInfo.NOTE_SHARE_FLAG:
                shareUrl = shareInfo.getShareUrl();
                imageUrl = shareInfo.getImagUrl();
                if (shareInfo.getObject_type().equals(String.valueOf(Constant.OBJECT_TYPE_NOTE))) {
                    String tag = "";
                    if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                        tag = "#" + shareInfo.getTags()[0] + "#";
                    }
                    if (!TextUtils.isEmpty(shareInfo.getTitle())) {
                        if (shareInfo.getTitle().length()>15){
                            title = subString(shareInfo.getTitle(), 15)+"...";
                        }else{
                            title = shareInfo.getTitle();
                        }
                    }else{
                        title = "我参与了豆花的"+tag+"话题";
                    }

                    if (!TextUtils.isEmpty(shareInfo.getDescription())) {
                        if (shareInfo.getDescription().length()>25){
                            content = subString(shareInfo.getDescription(), 25)+"...";
                        }else{
                            content = shareInfo.getDescription();
                        }
                    }else{
                        content = "快来围观吧~";
                    }


                } else if (shareInfo.getObject_type().equals(String.valueOf(Constant.OBJECT_TYPE_DRAW))) {
                    String tag = "";
                    if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                        tag = "【" + shareInfo.getTags()[0] + "】";
                    }
                    title = tag + shareInfo.getTitle();
                    title = subString(title, 15);
                    if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                        content = subString(shareInfo.getDescription(), 25);
                    } else {
                        content = "画师“" + shareInfo.getArticleAuthor() + "”作品";
                    }
                } else if (shareInfo.getObject_type().equals(String.valueOf(Constant.OBJECT_TYPE_COS))) {
                    String tag = "";
                    if (shareInfo.getTags() != null && shareInfo.getTags().length > 0) {
                        tag = "【" + shareInfo.getTags()[0] + "】";
                    }
                    title = tag + shareInfo.getTitle();
                    title = subString(title, 15);
                    if (shareInfo.getDescription() != null && !shareInfo.getDescription().isEmpty()) {
                        content = subString(shareInfo.getDescription(), 25);
                    } else {
                        content = "“" + shareInfo.getArticleAuthor() + "”的cos作品";
                    }
                }
                break;
            // 分享 QQ 漫画
            case ShareBeansInfo.CARTOON_SHARE_FLAG:
                if (!TextUtils.isEmpty(shareInfo.getTitle())) {
                    if (shareInfo.getTitle().length() > 15) {
                        title = subString(shareInfo.getTitle(),15) + "...";
                    }else{
                        title = shareInfo.getTitle();
                    }
                }else{
                    title = "豆花漫画看不停!";
                }
                content = "我最近在追的漫画，介绍给你";
                imageUrl = Constant.DOWN_URL_QQ;
                shareUrl = shareInfo.getShareUrl();
                break;

            default:
                break;
        }
        Bundle params = new Bundle();
        params.putInt(QQShare.SHARE_TO_QQ_KEY_TYPE,
                QQShare.SHARE_TO_QQ_TYPE_DEFAULT);
        params.putString(QQShare.SHARE_TO_QQ_TITLE, title);
        params.putString(QQShare.SHARE_TO_QQ_SUMMARY, content);
        params.putString(QQShare.SHARE_TO_QQ_EXT_STR, content);
        params.putString(QQShare.SHARE_TO_QQ_TARGET_URL, shareUrl);
        params.putString(QQShare.SHARE_TO_QQ_IMAGE_URL, imageUrl);
        params.putString(QQShare.SHARE_TO_QQ_APP_NAME, "豆花");
        QQService.getInstance().shareToQQ(mContext, params, new IUiListener() {

            @Override
            public void onError(UiError arg0) {

            }

            @Override
            public void onComplete(Object arg0) {
                if (shareInfo.getId() != null && shareInfo.getShareData() != null) {
                    HomeMainServices.shareStatistics(mContext,
                            String.valueOf(shareInfo.getSocial_type()),
                            shareInfo.getShareData().getObject_type(),shareInfo.getId(),shareInfo.shareUrl);
                }
            }

            @Override
            public void onCancel() {
                TTLog.d("tag", "task has been canceled");
            }
        });

    }

    private String subString(String des, int subLong) {
        String content = "";
        if (des != null) {
            if (des.length() < subLong) {
                content = des;
            } else {
                content = des.substring(0, subLong - 1) + "...";
            }
        }
        return content;
    }

    private String shareChannel(String shareUrl, String channel) {
        if (shareUrl.contains("?")) {
            shareUrl = shareUrl + "&channel=" + channel;
        } else {
            shareUrl = shareUrl + "?channel=" + channel;
        }
        return shareUrl;

    }


    private boolean isStringEmpty(String string) {
        if (string != null && !TextUtil.isEmpty(string)) {
            return false;
        } else {
            return true;
        }
    }

}